package cn.wolfcode.shop.cloud.mapper;


import domain.OrderInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;


@Mapper
public interface SeckillOrderInfoMapper {
    @Insert("insert into t_order_info " +
            "(order_no,user_id,good_id,good_img,delivery_addr_id,good_name,good_count,good_price,seckill_price,status,create_date,pay_date)" +
            " values " +
            "(#{orderNo},#{userId},#{goodId},#{goodImg},#{deliveryAddrId},#{goodName},#{goodCount},#{goodPrice},#{seckillPrice},#{status},#{createDate},#{payDate})")
    void save(OrderInfo orderInfo);


    @Select("select * from t_order_info where  order_no = #{orderNo}")
    OrderInfo queryByOrderNo(String orderNo);

    @Update("update t_order_info set status = 3 where order_no = #{orderNo} and status = 0")
    int cancelOrder(String orderNo);

    @Update("update t_order_info set status = #{status} ,pay_date=now() where order_no = #{orderNo} and status = 0 ")
    int updateStatus(@Param("orderNo") String orderNo, @Param("status") Integer status);

    @Update("update t_order_info set status=#{status} where order_no=#{orderNo} and status=0")
    int changOrderInfoStatus(@Param("orderNo") String orderNo, @Param("status") Integer status);
    @Update("update t_order_info set status=#{status},pay_date=now() where order_no=#{orderNo} and status=0")
    void changPayStatus(String orderNo, Integer status);
}
